home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / Drawn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  4.5 KB  |  156 lines

  1. /*
  2. //   (C) COPYRIGHT International Business Machines Corp. 1993
  3. //   All Rights Reserved
  4. //   Licensed Materials - Property of IBM
  5. //   US Government Users Restricted Rights - Use, duplication or
  6. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. //
  8.  
  9. //
  10. // Permission to use, copy, modify, and distribute this software and its
  11. // documentation for any purpose and without fee is hereby granted, provided
  12. // that the above copyright notice appear in all copies and that both that
  13. // copyright notice and this permission notice appear in supporting
  14. // documentation, and that the name of I.B.M. not be used in advertising
  15. // or publicity pertaining to distribution of the software without specific,
  16. // written prior permission. I.B.M. makes no representations about the
  17. // suitability of this software for any purpose.  It is provided "as is"
  18. // without express or implied warranty.
  19. //
  20. // I.B.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  21. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I.B.M.
  22. // BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  23. // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  24. // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  25. // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  26. //
  27. // Author:  John Spitzer, IBM AWS Graphics Systems (Austin)
  28. //
  29. */
  30.  
  31. #include "Drawn.h"
  32. #include <malloc.h>
  33.  
  34. void new_Drawn(DrawnPtr this)
  35. {
  36.     new_Test((TestPtr)this);
  37. /* Not adequately supported yet.  Will add as enhancement, if necessary
  38.     this->feedbackBuffer = NULL;
  39. */
  40. }
  41.  
  42. void delete_Drawn(TestPtr thisTest)
  43. {
  44.     DrawnPtr this = (DrawnPtr)thisTest;
  45.  
  46. /* Not adequately supported yet.  Will add as enhancement, if necessary
  47.     if (this->feedbackBuffer) free(this->feedbackBuffer);
  48. */
  49.     delete_Test(thisTest);
  50. }
  51.  
  52. int Drawn__SetState(TestPtr thisTest)
  53. {
  54.     DrawnPtr this = (DrawnPtr)thisTest;
  55.     int windowDim;
  56.  
  57.     /* set parent GL state */
  58.     if (Test__SetState(thisTest) == -1) return -1;
  59.  
  60.     /* set own state */
  61.  
  62.     windowDim = min(this->environ.windowWidth, this->environ.windowHeight);
  63.  
  64. /* Not adequately supported yet.  Will add as enhancement, if necessary
  65.     if (this->renderMode==GL_FEEDBACK) {
  66.     this->feedbackBuffer = (GLfloat*)malloc(100000*sizeof(GLfloat));
  67.         CheckMalloc(this->feedbackBuffer);
  68.     glFeedbackBuffer(100000,this->feedbackType,this->feedbackBuffer);
  69.     }
  70. */
  71.     glRenderMode(this->renderMode);
  72.  
  73.     glViewport(0, 0, windowDim, windowDim);
  74.  
  75.     /* set up scissoring */
  76.     if (this->scissorWidth == -1) {
  77.     this->scissorWidth = this->environ.windowWidth;
  78.     }
  79.     if (this->scissorHeight == -1) {
  80.     this->scissorHeight = this->environ.windowHeight;
  81.     }
  82.  
  83.     if (this->scissorTest) {
  84.     glScissor(this->scissorX, this->scissorY,
  85.                   this->scissorWidth, this->scissorHeight);
  86.     glEnable(GL_SCISSOR_TEST);
  87.     } else {
  88.     glDisable(GL_SCISSOR_TEST);
  89.     }
  90.  
  91.     if (this->dithering) {
  92.     glEnable(GL_DITHER);
  93.     } else {
  94.     glDisable(GL_DITHER);
  95.     }
  96.  
  97.     glDrawBuffer(this->drawBuffer);
  98.  
  99.     /* set up masking */
  100.     if (this->environ.bufConfig.rgba) {
  101.     switch (this->colorMask) {
  102.             case TTTT:
  103.         glColorMask(GL_TRUE , GL_TRUE , GL_TRUE , GL_TRUE );
  104.         break;
  105.             case TTTF:
  106.         glColorMask(GL_TRUE , GL_TRUE , GL_TRUE , GL_FALSE);
  107.         break;
  108.             case TTFT:
  109.         glColorMask(GL_TRUE , GL_TRUE , GL_FALSE, GL_TRUE );
  110.         break;
  111.             case TTFF:
  112.         glColorMask(GL_TRUE , GL_TRUE , GL_FALSE, GL_FALSE);
  113.         break;
  114.             case TFTT:
  115.         glColorMask(GL_TRUE , GL_FALSE, GL_TRUE , GL_TRUE );
  116.         break;
  117.             case TFTF:
  118.         glColorMask(GL_TRUE , GL_FALSE, GL_TRUE , GL_FALSE);
  119.         break;
  120.             case TFFT:
  121.         glColorMask(GL_TRUE , GL_FALSE, GL_FALSE, GL_TRUE );
  122.         break;
  123.             case TFFF:
  124.         glColorMask(GL_TRUE , GL_FALSE, GL_FALSE, GL_FALSE);
  125.         break;
  126.             case FTTT:
  127.         glColorMask(GL_FALSE, GL_TRUE , GL_TRUE , GL_TRUE );
  128.         break;
  129.             case FTTF:
  130.         glColorMask(GL_FALSE, GL_TRUE , GL_TRUE , GL_FALSE);
  131.         break;
  132.             case FTFT:
  133.         glColorMask(GL_FALSE, GL_TRUE , GL_FALSE, GL_TRUE );
  134.         break;
  135.             case FTFF:
  136.         glColorMask(GL_FALSE, GL_TRUE , GL_FALSE, GL_FALSE);
  137.         break;
  138.             case FFTT:
  139.         glColorMask(GL_FALSE, GL_FALSE, GL_TRUE , GL_TRUE );
  140.         break;
  141.             case FFTF:
  142.         glColorMask(GL_FALSE, GL_FALSE, GL_TRUE , GL_FALSE);
  143.         break;
  144.             case FFFT:
  145.         glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE );
  146.         break;
  147.             case FFFF:
  148.         glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
  149.         break;
  150.     }
  151.     } else {
  152.     glIndexMask(this->indexMask);
  153.     }
  154.     return 0;
  155. }
  156.